#include<bits/stdc++.h>
using namespace std;
int T;
int n,m,L,V;
const double eps=-0.00000001;
const int N=1e5+2;
const int M=3002;
int cc;
bool ab(double x){
    if(x<0)return -x;
    return x;
}
bool eq(double a,double b){
    if(ab(a-b)<=eps)return 1;
    return 0;
}
bool bigg(double a,double b){
    if(a-b>eps)return 1;
    return 0;
}
double d[N],v[N],a[N];
double p[N];
vector<int> car[N];
bitset<N> used;
bool f;
void dfs(int cnt,int idx,int nowcnt,int nown){
    if(f)return ;
    if(nowcnt>cnt){
        if(nown==cc){
            f=1;
            return ;
        }
        return ;
    }
    if(nown==cc){
        f=1;
        return ;
    }
    for(int i=idx;i<=m;i++){
        int ct=0;
        for(auto v:car[i]){
            if(!used[v] && v>0){
                used[v]=1;
                ct++;
            }
        }
        dfs(cnt,i+1,nowcnt+1,nown+ct);
    }

}
int check(){
    int baoliu=0;
    for(int i=1;i<=m;i++){
        f=0;
        dfs(i,0,0,0);
        if(f)return i;
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;
        for(int i=1;i<=m;i++){
            car[i].clear();
        }
        for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)cin>>p[i];
        sort(p+1,p+1+m);
        cc=0;
        for(int i=1;i<=n;i++){
            if(a[i]==0){
                if(v[i]>V && d[i]<L){
                    int ctr=lower_bound(p+1,p+1+n,d[i])-p;
                    for(int i=ctr;i<=n;i++)car[i].push_back(i);
                    cc++;
                }
                continue;
            }
            if(a[i]<0){
                if(v[i]<V || d[i]>L)continue;
                double luchen=d[i]+(V*V-v[i]*v[i])/(2.0*a[i]);
                int ctr=lower_bound(p+1,p+1+n,d[i])-p-1;
                int stp=lower_bound(p+1,p+1+n,luchen)-p;
                if(eq(p[ctr],luchen) || bigg(luchen,p[ctr+1])){
                    if(eq(p[stp],luchen))stp--;
                    for(int j=ctr;j<=stp;j++)car[j].push_back(i);
                    cc++;
                    continue;
                }
            }
            if(a[i]>0){
                if(v[i]>V && d[i]<L){
                    cc++;
                    continue;
                }
                double luchen=d[i]+(v[i]*v[i]-V*V)/(2.0*a[i]);
                int stp=lower_bound(p+1,p+1+n,luchen)-p;
                if(bigg(L,luchen)){
                    if(eq(p[stp],luchen))stp--;
                    cc++;
                    for(int j=1;j<=stp;j++)car[j].push_back(i);
                    continue;
                }
            }
        }
        cout<<cc<<' '<<check()<<'\n';
    }
    return 0;
}
